/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 *
 * @author Laurent WOUTERS
 */
public class QuerySolution {
    private Map<String, xowl.lang.actions.QueryVariable> mapNames;
    private Map<xowl.lang.actions.QueryVariable, xowl.lang.runtime.Value> mapValues;

    public xowl.lang.runtime.Value getValue(String var) { return mapValues.get(mapNames.get(var)); }
    public xowl.lang.runtime.Value getValue(xowl.lang.actions.QueryVariable var) { return mapValues.get(var); }
    public Set<xowl.lang.actions.QueryVariable> getVariables() { return mapValues.keySet(); }
    
    public QuerySolution(Map<xowl.lang.actions.QueryVariable, xowl.lang.runtime.Value> values) {
        mapValues = values;
        mapNames = new HashMap<String, xowl.lang.actions.QueryVariable>();
        for (xowl.lang.actions.QueryVariable var : values.keySet())
            mapNames.put(var.getName(), var);
    }
}
